<?php

namespace addons\unidrink\model;

use think\Model;
use traits\model\SoftDelete;

/**
 * @property int $id
 * @property int $score
 */
class ScoreProduct extends Model
{
    use SoftDelete;

    // 表名
    protected $name = 'unidrink_score_product';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    /**
     * 处理图片
     * @param $value
     * @return string
     */
    public function getImageAttr($value) {
        return Config::getImagesFullUrl($value);
    }

    /**
     * 处理图片
     * @param $value
     * @param $data
     * @return string
     */
    public function getImagesAttr($value, $data){
        $images = explode(',', $data['images']);
        foreach ($images as &$image) {
            $image = Config::getImagesFullUrl($image);
        }
        return $images;
    }
}